const router = require('express').Router({

});
const { check, validationResult } = require('express-validator'); //数据验证
const chooseControllers = require("../../controllers/chooseControllers");
/* GET */
router.get(
  '/',
  [
    check('pageNo').notEmpty().withMessage('页码不能为空'),
    check('pageSize').notEmpty().withMessage('条数不能为空')
  ],
  async function (req, res, next) {
    const errors = validationResult(req)
    if (!errors.isEmpty()) {
      return res.sendResult(null, 400, errors.array()[0].msg);
    }
    let data = await chooseControllers
                    .selectList(
                      req.query.pageNo,
                      req.query.pageSize,
                      req.query.courseName,
                      req.query.major,
                      req.query.className
                    );

    res.sendResult(data,200,"请求成功");
    
  });

module.exports = router;
